{% extends "base.html" %}
{# Copyright The IETF Trust 2015, All Rights Reserved #}
{% load origin %}
{% load static django_bootstrap5 widget_tweaks %}
{% block title %}Edit Interim Request{% endblock %}
{% block pagehead %}
    <link rel="stylesheet" href="{% static 'ietf/css/select2.css' %}">
    <link rel="stylesheet" href="{% static 'ietf/css/datepicker.css' %}">
{% endblock %}
{% block content %}
    {% origin %}
    <h1>Edit Interim Meeting Request</h1>
    {% if form.non_field_errors %}<div class="my-3 alert alert-danger">{{ form.non_field_errors }}</div>{% endif %}
    <form id="interim-request-form" method="post" class="my-3">
        {% csrf_token %}
        {% bootstrap_field form.group layout='horizontal' %}
        <input type="hidden" name="group" value="{{ form.group.value }}">
        {% bootstrap_field form.in_person layout='horizontal' %}
        <div class="row mb-3">
            <div class="offset-md-2 col-md-10">
                {% render_field form.approved class="form-check-input" %}
                {% bootstrap_label "Preapproved by AD" label_for=form.approved.id_for_label %}
            </div>
        </div>
        {% bootstrap_field form.city layout='horizontal' %}
        {% bootstrap_field form.country layout='horizontal' %}
        {% bootstrap_field form.time_zone layout='horizontal' %}
        {{ formset.management_form }}
        {% if formset.non_form_errors %}<div class="my-3 alert alert-danger">{{ formset.non_form_errors }}</div>{% endif %}
        {% for form in formset %}
            <div class="fieldset{% if forloop.last %} template d-none{% endif %}">
                <hr class="my-4">
                {% bootstrap_form form layout='horizontal' %}
                <button name="id_session_set-{{ forloop.counter0 }}-delete-button"
                        type="button"
                        class="btn btn-danger offset-md-2 d-none btn-delete">
                    Delete session
                </button>
            </div>
        {% endfor %}
        <div class="my-3">
            <button id="add_session" type="button" class="btn btn-primary offset-md-2">
                <i class="bi bi-plus" aria-hidden="true"></i>Add session
            </button>
        </div>
        <div class="my-3">
            <button type="submit" class="btn btn-primary">Submit</button>
            <a class="btn btn-secondary float-end"
               href="{% url 'ietf.meeting.views.interim_request_details' number=meeting.number %}">
                Back
            </a>
        </div>
    </form>
{% endblock %}
{% block js %}
    <script src="{% static 'ietf/js/datepicker.js' %}"></script>
    <script src="{% static 'ietf/js/select2.js' %}"></script>
    <script src="{% static 'ietf/js/meeting-interim-request.js' %}"></script>
{% endblock %}